﻿package images {
	import flash.display.MovieClip;
	import flash.utils.Timer;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.events.MouseEvent;
	
	public class c_mech extends MovieClip {
		private var rIndex: Number = 0;
		private var speed: Number = 0;
		private var maxSpeed: Number = 5;
		private var focus: Boolean = false;
		private var timer: Timer;
		
		function c_mech() {
			super();
			timer = new Timer(40);
			toBegin();
		}
		
		function toBegin(): void {
			timer.addEventListener(TimerEvent.TIMER, function(e: TimerEvent): void {
				rIndex += speed;													   	
				s1.rotation = rIndex;
				s2.rotation = -rIndex * 20 / 8;
				if (focus) {
					if (speed < maxSpeed) speed += (maxSpeed - speed) / 5;
				} else if (speed > 0) speed -= speed / 5;
			});
			
			timer.start();
		}
		
		public function doFocus(a_focus: Boolean): void {
			focus = a_focus;
		}
	}
}